PATTERN_PATH=/mnt/e/project-pattern/
# 安装nacos
 if [[ -z "$(docker images -q nacos/nacos-server:1.4.2 2> /dev/null)" ]]; then
    docker pull nacos/nacos-server:1.4.2
  else
    echo "nacos installed"
  fi

# 创建目录及配置
  if [[ -z "$(docker ps -aqf "name=nacos-pattern")" ]]; then
     mkdir -p /opt/nacos/logs/
      mkdir -p /opt/nacos/init.d/
      cp $PATTERN_PATH/.environment/init/docker/nacos/custom.properties /opt/nacos/init.d/
    #	运行  project-pattern 为宿主地址
      docker run -d \
      -e PREFER_HOST_MODE=ip \
      -e MODE=standalone \
      -e SPRING_DATASOURCE_PLATFORM=mysql \
      -e NACOS_SERVER_PORT=8848 \
      -e MYSQL_SERVICE_HOST=project-pattern \
      -e MYSQL_SERVICE_PORT=3306 \
      -e MYSQL_SERVICE_USER=root \
      -e MYSQL_SERVICE_PASSWORD=p123456 \
      -e MYSQL_SERVICE_DB_NAME=nacos_config \
      -e MYSQL_SERVICE_DB_PARAM='characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC' \
      -v /opt/nacos/logs:/home/nacos/logs \
      -v /opt/nacos/init.d:/home/nacos/init.d \
      -p 10001:8848 \
      --name nacos-pattern \
      --add-host=project-pattern:192.168.0.101 \
      --restart=always \
      nacos/nacos-server
  else
      echo "nacos-pattern running"
  fi

#登陆nacos控制台导入配置 nacos/nacos
  # 新建命名空间:pattern 导入最新配置压缩包$PATTERN_PATH/.environment/init/nacos/nacos_config_export_*.zip